<!--
 * @Author: wangming
 * @Date: 2021-04-01 17:41:49
 * @LastEditors: wangming
 * @LastEditTime: 2022-02-07 17:03:41
 * @Description: file content
-->
<template>
  <div v-if="value.__config.matchRule == 'SECTION_MATCH'">
    <span class="el-form-item__label" style="float: none">默认值</span>
    <el-form-item :label="'开始' + labelStr">
      <!-- <el-select v-model="value.__config.isCurrentDate[0]" placeholder="请选择">
        <el-option :label="'系统' + labelStr" value="SYSTEM"> </el-option>
        <el-option label="自定义" value="CUSTOM"> </el-option>
      </el-select> -->
      <el-radio-group v-model="value.__config.isCurrentDate[0]" name="startTime">
        <el-radio :label="'SYSTEM'">{{ "系统" + labelStr }}</el-radio>
        <el-radio :label="'CUSTOM'">自定义</el-radio>
      </el-radio-group>
      <el-date-picker
        v-if="
          value.tagName == 'SearchDatePicker' &&
          value.__config.isCurrentDate[0] == 'CUSTOM'
        "
        @change="dateChange"
        v-model="value.defaultValue[0]"
        :format="
          value.__config.format.replace('YYYY', 'yyyy').replace('DD', 'dd')
        "
        value-format="timestamp"
        :type="dateConfig.type"
        placeholder="选择日期"
      >
      </el-date-picker>
      <el-time-picker
        v-else-if="
          value.tagName == 'SearchTimePicker' &&
          value.__config.isCurrentDate[0] == 'CUSTOM' &&
          value.__config.timeType == 2
        "
        v-model="value.defaultValue[0]"
        format="HH:mm:ss"
        value-format="HH:mm:ss"
        placeholder="选择时间"
      >
      </el-time-picker>
      <el-time-select
        v-else-if="
          value.tagName == 'SearchTimePicker' &&
          value.__config.isCurrentDate[0] == 'CUSTOM' &&
          value.__config.timeType == 1
        "
        v-model="value.defaultValue[0]"
        format="HH:mm"
        :picker-options="{
          start: '00:00',
          step: step,
          end: '23:59',
        }"
        placeholder="选择时间"
      >
      </el-time-select>
    </el-form-item>
    <el-form-item :label="'结束' + labelStr">
      <!-- <el-select v-model="value.__config.isCurrentDate[1]" placeholder="请选择">
        <el-option :label="'系统' + labelStr" value="SYSTEM"> </el-option>
        <el-option label="自定义" value="CUSTOM"> </el-option>
      </el-select> -->
      <el-radio-group v-model="value.__config.isCurrentDate[1]" name="endTime">
        <el-radio :label="'SYSTEM'">{{ "系统" + labelStr }}</el-radio>
        <el-radio :label="'CUSTOM'">自定义</el-radio>
      </el-radio-group>
      <el-date-picker
        v-if="
          value.tagName == 'SearchDatePicker' &&
          value.__config.isCurrentDate[1] == 'CUSTOM'
        "
        v-model="value.defaultValue[1]"
        :format="
          value.__config.format.replace('YYYY', 'yyyy').replace('DD', 'dd')
        "
        value-format="timestamp"
        :type="dateConfig.type"
        placeholder="选择日期"
      >
      </el-date-picker>
      <el-time-picker
        v-else-if="
          value.tagName == 'SearchTimePicker' &&
          value.__config.isCurrentDate[1] == 'CUSTOM' &&
          value.__config.timeType == 2
        "
        v-model="value.defaultValue[1]"
        format="HH:mm:ss"
        value-format="HH:mm:ss"
        placeholder="选择时间"
      >
      </el-time-picker>
      <el-time-select
        v-else-if="
          value.tagName == 'SearchTimePicker' &&
          value.__config.isCurrentDate[1] == 'CUSTOM' &&
          value.__config.timeType == 1
        "
        v-model="value.defaultValue[1]"
        format="HH:mm"
        :picker-options="{
          start: '00:00',
          step: step,
          end: '23:59',
        }"
        placeholder="选择时间"
      >
      </el-time-select>
    </el-form-item>
  </div>
  <div v-else>
    <el-form-item label="默认值">
      <!-- <el-select v-model="value.__config.isCurrentDate[0]" placeholder="请选择">
        <el-option :label="'系统' + labelStr" value="SYSTEM"> </el-option>
        <el-option label="自定义" value="CUSTOM"> </el-option>
      </el-select> -->
      <el-radio-group v-model="value.__config.isCurrentDate[0]">
        <el-radio :label="'SYSTEM'">{{ "系统" + labelStr }}</el-radio>
        <el-radio :label="'CUSTOM'">自定义</el-radio>
      </el-radio-group>
      <el-date-picker
        v-if="
          value.tagName == 'SearchDatePicker' &&
          value.__config.isCurrentDate[0] == 'CUSTOM'
        "
        @change="dateChange"
        v-model="value.defaultValue[0]"
        :format="
          value.__config.format.replace('YYYY', 'yyyy').replace('DD', 'dd')
        "
        value-format="timestamp"
        :type="dateConfig.type"
        placeholder="选择日期"
      >
      </el-date-picker>
      <el-time-picker
        v-else-if="
          value.tagName == 'SearchTimePicker' &&
          value.__config.isCurrentDate[0] == 'CUSTOM' &&
          value.__config.timeType == 2
        "
        v-model="value.defaultValue[0]"
        format="HH:mm:ss"
        value-format="HH:mm:ss"
        placeholder="选择时间"
      >
      </el-time-picker>
      <el-time-select
        v-else-if="
          value.tagName == 'SearchTimePicker' &&
          value.__config.isCurrentDate[0] == 'CUSTOM' &&
          value.__config.timeType == 1
        "
        v-model="value.defaultValue[0]"
        format="HH:mm"
        :picker-options="{
          start: '00:00',
          step: step,
          end: '23:59',
        }"
        placeholder="选择时间"
      >
      </el-time-select>
    </el-form-item>
  </div>
</template>

<script>
import basicmixins from "../../basicmixins";
import { dateConfig } from "@/utils/dateLimitTypeList";
export default {
  mixins: [basicmixins],
  computed: {
    labelStr() {
      return this.value.tagName == "SearchDatePicker" ? "日期" : "时间";
    },
    dateConfig() {
      return (
        dateConfig.find((i) => this.value.__config.format === i.format) || {}
      );
    },
    step() {
      const timeStep = {
        1: "00:01",
        5: "00:05",
        15: "00:15",
        30: "00:30",
      };
      const step = timeStep[this.value.__config.timefilter] || "00:01";
      return step;
    },
  },
  data() {
    return {};
  },
  methods: {
    dateChange(event) {},
  },
};
</script>

<style lang="scss" scoped></style>
